package com.sise.studentInfoSystem.util;

import java.util.Random;

/**
 * @Author zzp
 * @Desc
 * @Date 2020/7/5
 */
public class CheckCodeUtil {

    public static int getA() {
        String base = "1234567890";
        int size = base.length();
        Random r = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 1; i <= 1; i++) {
            //产生0到size-1的随机值
            int index = r.nextInt(size);
            //在base字符串中获取下标为index的字符
            char c = base.charAt(index);
            //将c放入到StringBuffer中去
            sb.append(c);
        }
        return Integer.parseInt(sb.toString());
    }

    public static int getB() {
        String base = "1234567890";
        int size = base.length();
        Random r = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 1; i <= 2; i++) {
            //产生0到size-1的随机值
            int index = r.nextInt(size);
            //在base字符串中获取下标为index的字符
            char c = base.charAt(index);
            //将c放入到StringBuffer中去
            sb.append(c);
        }
        return Integer.parseInt(sb.toString());
    }
}
